import { $api1 } from '../index';
import { Iresponse } from '../require/type';

// interface Imultidata {
//     banner: any
//     dKeyword: any
//     keywords: any
//     recommend: any
// }
// $api1.request<Imultidata>({
//     url:'/home/multidata',
//     interceptors: {
//         requestSuccessFn: (req) => {
//             console.log('/home/multidata的请求成功拦截');
//             return req
//         },
//         // requestFailureFn: (err) => {
//         //     console.log('/home/multidata的请求失败拦截');
//         //     return err
//         // },
//         responeseSuccessFn: (res) =>{
//             console.log('/home/multidata的响应成功拦截');
//             return res.data
//         },
//         responeseFailureFn: (err) => {
//             console.log('/home/multidata的响应失败拦截');
//             return err
//         }
//     }
// }).then(res => {
//     console.log(res.banner);
// })
export interface IpageData {
  id: string;
  text: string;
  updateTime: string;
  createTime: string;
  userId: number;
}

export interface Ipage {
  code: number;
  data: IpageData[];
  message: any;
  total: number;
}

export interface Ilogin {
  token: string;
  level: number;
}

export interface IUser {
  id: string;
  name: string;
  level: number;
  telPhone: string;
  avatar: string;
}

// 登录
export const ftLogin = (data: any) => {
  return $api1.post<Iresponse<Ilogin>>({
    url: '/users/login',
    data,
  });
};
// 用户信息
export const ftUserinfo = () => {
  return $api1.get<Iresponse<IUser>>({
    url: '/users/userinfo',
    headers: {
      shouldToken: false,
    },
  });
};

// 列表
export const ftPage = (data: any) => {
  return $api1.post<Ipage>({
    url: '/users/page',
    data,
  });
};

// 新增
export const ftCreate = (data: any) => {
  return $api1.post<Iresponse>({
    url: '/users/create',
    data,
  });
};

// 删除
export const ftDelete = (ids: string[]) => {
  return $api1.post<Iresponse>({
    url: '/users/delete',
    data: { ids },
  });
};

// 修改
export const ftUpdate = (data: any) => {
  return $api1.post<Iresponse>({
    url: '/users/update',
    data,
  });
};

// 修改密码
export const ftUpdatePassword = (data: any) => {
  return $api1.post<Iresponse>({
    url: '/users/resetpassword',
    data,
  });
};
